/*
 * $Id: iptc.h,v 1.37 2005/12/05 15:11:29 bacon Exp $
 *
   Copyright 2005-2009 Chung, Hyung-Hwan.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an  BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */

#ifndef _XP_LIB_LNX_IPTC_H_
#define _XP_LIB_LNX_IPTC_H_

#include <xp/lnx/iptc.h>

#include "libiptc.h"
#include <netinet/ether.h>


#if defined(HAVE_LINUX_NETFILTER_IPV4_IPT_MARK_H)
	/* THIS PART IS MOSTLY FOR REDHAT/CENTOS */

#	include <linux/netfilter_ipv4/ip_conntrack.h>
#	include <linux/netfilter_ipv4/ip_nat_rule.h>
#	include <linux/netfilter_ipv4/ipt_mac.h>
#	include <linux/netfilter_ipv4/ipt_limit.h>
#	include <linux/netfilter_ipv4/ipt_mark.h>
#	include <linux/netfilter_ipv4/ipt_hashlimit.h>
#	include <linux/netfilter_ipv4/ipt_MARK.h>
#	include <linux/netfilter_ipv4/ipt_REJECT.h>
#	include <linux/netfilter_ipv4/ipt_CLASSIFY.h>
#	include <linux/netfilter_ipv4/ipt_physdev.h>
#	include <linux/netfilter_ipv4/ipt_state.h>

#	if defined(HAVE_LINUX_NETFILTER_IPV4_IPT_CONNLIMIT_H)
#		include <linux/netfilter_ipv4/ipt_connlimit.h>
#	elif defined(HAVE_LINUX_NETFILTER_XT_CONNLIMIT_H)
#		include <linux/netfilter/xt_connlimit.h>
#		define ipt_connlimit_info xt_connlimit_info
#	else
		struct ipt_connlimit_data;
		struct ipt_connlimit_info 
		{
			int limit;
			int inverse;
			u_int32_t mask;
			struct ipt_connlimit_data *data __attribute__((aligned(8)));
		};
#	endif
#else

	/* THIS PART STILL DOES NOT WORK. 
	 * LINUX KERNEL CHANGES ARE TOO DRASTIC */
#	include <linux/netfilter/nf_conntrack_common.h>

#	include <linux/netfilter_ipv4/nf_nat.h>
#	define ip_nat_multi_range nf_nat_multi_range

#	include <linux/netfilter/xt_mac.h>
#	define ipt_mac_info xt_mac_info

#	include <linux/netfilter/xt_limit.h>
#	define IPT_LIMIT_SCALE XT_LIMIT_SCALE
#	define ipt_rateinfo xt_rateinfo

#	include <linux/netfilter/xt_mark.h>
#	if defined(HAVE_STRUCT_XT_MARK_INFO)
#		define ipt_mark_info xt_mark_info
#	elif defined(HAVE_STRUCT_XT_MARK_MTINFO1)
#		define ipt_mark_info xt_mark_mtinfo1
#	else
#		error no good ipt_mark_info replacement defined
#	endif

#	include <linux/netfilter/xt_hashlimit.h>
#	define ipt_hashlimit_info xt_hashlimit_info
#	define IPT_HASHLIMIT_SCALE XT_HASHLIMIT_SCALE

#	include <linux/netfilter/xt_connlimit.h>
#	define ipt_connlimit_info xt_connlimit_info

#	include <linux/netfilter/xt_MARK.h>
#	if defined(HAVE_STRUCT_XT_MARK_TGINFO2)
#		define ipt_mark_target_info xt_mark_tginfo2
#	else
		/* Version 0 */
#		define ipt_mark_target_info xt_mark_target_info
		/* Version 1 */
#		define IPT_MARK_SET    XT_MARK_SET
#		define IPT_MARK_AND    XT_MARK_AND
#		define IPT_MARK_OR     XT_MARK_OR
#		define ipt_mark_target_info_v1 xt_mark_target_info_v1
#	endif

#	include <linux/netfilter_ipv4/ipt_REJECT.h>

#	include <linux/netfilter/xt_CLASSIFY.h>
#	define ipt_classify_target_info xt_classify_target_info

#	include <linux/netfilter/xt_physdev.h>
#	define ipt_physdev_info xt_physdev_info
#	define IPT_PHYSDEV_OP_IN               XT_PHYSDEV_OP_IN
#	define IPT_PHYSDEV_OP_OUT              XT_PHYSDEV_OP_OUT
#	define IPT_PHYSDEV_OP_BRIDGED          XT_PHYSDEV_OP_BRIDGED
#	define IPT_PHYSDEV_OP_ISIN             XT_PHYSDEV_OP_ISIN
#	define IPT_PHYSDEV_OP_ISOUT            XT_PHYSDEV_OP_ISOUT
#	define IPT_PHYSDEV_OP_MASK             XT_PHYSDEV_OP_MASK

#	include <linux/netfilter/xt_state.h>
#	define ipt_state_info xt_state_info
#	define IPT_STATE_BIT(x) XT_STATE_BIT(x)
#	define IPT_STATE_INVALID XT_STATE_INVALID
#	define IPT_STATE_UNTRACKED XT_STATE_UNTRACKED

#endif

#endif
